package com.szyt.basicframe.pojo.request.usermanagement;

import com.szyt.basicframe.annotation.UserNameUnique;
import com.szyt.basicframe.common.OperationTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

@Data
public class CreateUserRequest {
    @NotBlank(message = "用户名不能为空")
    @Size(min = 4, max = 20, message = "用户名长度必须在4到20个字符之间")
    @Pattern(regexp = "^[a-zA-Z0-9_]+$", message = "用户名只能包含字母、数字和下划线")
    @UserNameUnique(type = OperationTypeEnum.INSERT, message = "用户名已存在")
    private String userName;

    @NotBlank(message = "密码不能为空")
    @Size(min = 8, max = 20, message = "密码长度必须在8到20个字符之间")
    @Pattern(
            regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]+$",
            message = "密码必须包含至少一个大写字母、一个小写字母、一个数字和一个特殊字符"
    )
    private String password;

    @ApiModelProperty("用户昵称")
    private String nickName;

    @ApiModelProperty("性别，0=男，1=女，2=其他")
    private String sex;

    @ApiModelProperty("电话号码")
    private String tel;

    @ApiModelProperty("邮箱")
    private String email;
}
